home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / shower.lua < prev    next >
Text File  |  2004-01-29  |  3KB  |  80 lines

  1. -- shower state machine
  2.  
  3. beginStateMachine()
  4.  
  5.     onMsg("buildMenu", function(msg)
  6.     
  7.         if (repairMenu()) then return end
  8.     
  9.         -- build the pie menu
  10.         clearPieMenu();
  11.         local button ;
  12.         button = addPieMenuButton("pm_shower", "shower");
  13.         button.addDescription(ACTIVITY, "shower");
  14.         button.addDescription(ACTIVITY, "improveObjectTidiness");
  15.         -- button.addIcon("guiIconHygiene");
  16.     end )
  17.     
  18.     --take a shower
  19.     onMsg("shower", function(msg)
  20.         -- get the game object server
  21.         local gameObjectServer = getGameObjectServer();
  22.         -- get character who initiated this action
  23.         local character = getStateObjectFromID(msg.sender);
  24.         -- if this is broken: abort characters action
  25.         if abortIfBroken(character) then return end;        
  26.         -- walk to the closest action point
  27.         local actionPoint = character.getFreeActionPoint(this, "enter");
  28.         if (actionPoint) then
  29.         -- get the walk state object
  30.             local wso = character.walkSO;
  31.             -- create state machine contexts
  32.             local wsoContext = StateMachineContext();
  33.             -- store the action point
  34.             wsoContext.storeData("actionPointName", actionPoint.getName());
  35.             if (wso.walkToActionPoint(actionPoint)) then
  36.                 wso.queueStateMachine("showerChar.undressOutside", this, wsoContext);
  37.             else
  38.                 print("no pathfound");
  39.                 instantAbort(character, EMOTICON_NOPATH, "emoThink")
  40. --                character.setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  41. --                sendMsg("emoThink", character.walkSO);
  42.             end
  43.         else
  44.             print("no action point found");
  45.             instantAbort(character, EMOTICON_CANNOT, "emoThink")
  46. --            character.setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  47. --            sendMsg("emoThink", character.walkSO);
  48.         end
  49.     end )
  50.     
  51.     
  52.     -- repair
  53.     onMsg("repair", function(msg)
  54.     
  55.         print("onMsg repair");
  56.         -- get character who initiated this action
  57.         local character = getStateObjectFromID(msg.sender);
  58.         -- walk to the closest action point
  59.         local actionPoint = character.getFreeActionPoint(this, "repair");
  60.         -- get the walk state object
  61.         local wso = character.walkSO;
  62.         if (actionPoint) then
  63.             -- create state machine contexts
  64.             local wsoContext = StateMachineContext();
  65.             -- store the action point
  66.             wsoContext.storeData("actionPointName", actionPoint.getName());
  67.             if (wso.walkToActionPoint(actionPoint)) then
  68.                 wso.queueStateMachine("repairChar.repairStart", this, wsoContext);
  69.             else
  70.                 print("no path found");
  71.                 instantAbort(character, EMOTICON_NOPATH, "emoThink")
  72.             end
  73.         else
  74.             print("no action point found");
  75.             instantAbort(character, EMOTICON_CANNOT, "emoThink")
  76.         end
  77.     end )
  78.                 
  79. endStateMachine()
  80.